package com.yyds.controller;


import com.yyds.common.MyJSON;
import com.yyds.common.R;
import com.yyds.pojo.HospitalDoctor;
import com.yyds.service.HospitalDoctorService;
import com.yyds.vo.HospitalDoctorPieVo;
import com.yyds.vo.HospitalDoctorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/hospital/doctor")
public class HospitalDoctorController {

    @Autowired
    @Qualifier("HospitalDoctorService")
    private HospitalDoctorService hospitalDoctorService;

//    //查询全部医生
//    @RequestMapping("/queryAllDoctor")
//    public MyJSON<HospitalDoctor> queryAllHospitalDoctorController(@RequestParam Map<String,Object> params){
//
//        return hospitalDoctorService.queryAllHospitalDoctorService(params);
//    }

    //查询全部医生
    @RequestMapping("/queryAllDoctor")
    public MyJSON<HospitalDoctorVo> queryAllHospitalDoctorController(@RequestParam Map<String,Object> params){
        return hospitalDoctorService.queryAllHospitalDoctorService(params);
    }

    //添加医生信息
    @RequestMapping("/insertDoctor")
    public R insertHospitalDoctorController(HospitalDoctor hospitalDoctor){
        Integer i = hospitalDoctorService.insertHospitalDoctorService(hospitalDoctor);
        return i > 0 ? R.ok() : R.error();
    }
    //删除医生信息
    @RequestMapping("/deleteDoctor")
    public R deleteHospitalDoctorController(Integer doctor_id){
        Integer i = hospitalDoctorService.deleteHospitalDoctorService(doctor_id);
        return i > 0 ? R.ok() : R.error();
    }
    //修改医生信息
    @RequestMapping("/updateDoctor")
    public R updateHospitalDoctorController(HospitalDoctor doctor){
        System.out.println("添加医生信息"+doctor);
        Integer i = hospitalDoctorService.updateHospitalDoctorService(doctor);
        return i > 0 ? R.ok() : R.error();
    }

    @RequestMapping("/echartPic")
    public R echartPic(){
        List<HospitalDoctorPieVo> list = hospitalDoctorService.sexPicHospitalDoctorService();
        System.out.println(""+list);
        return R.ok().data("pie",list);
//        return R.ok();
    }

}
